package tech.aistar.day05;

/**
 * 本类用来演示:
 *
 * @author: success
 * @date: 2022/7/22 9:48 上午
 */
public class Dog extends Animal{
    //定义特有的属性
    private double loyal;//忠诚度

    public Dog(){
        //super();
        System.out.println("Dog...");
    }

    //全参构造
    public Dog(String name,int age,double loyal){
        super(name,age);//父类的带参构造
        this.loyal = loyal;
        System.out.println("Dog全参构造...");
    }

    public void setLoyal(double loyal) {
        this.loyal = loyal;
    }

    public double getLoyal() {
        return loyal;
    }

//重写父类中的spark方法


    @Override
    public void spark() {
        System.out.println("汪汪~~~");
    }


    //定义子类特有的方法
    public void watchDoor(){
        System.out.println("狗可以看门~~~");
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder("Dog{");
        sb.append("loyal=").append(loyal);
        sb.append('}');
        return super.toString()+sb.toString();
    }
}
